﻿
@page "/Fin/PaymentDetail/Create"
@using nERP.ViewModel.Fin.PaymentDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
  <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit" >
    <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
      <BootstrapInput @bind-Value="@Model.Entity.Seq"/>
      <Select @bind-Value="@Model.Entity.PayId" Items="AllPays" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g330aacee97794959bc964fe92a0f2f8e"/>
      <BootstrapInput @bind-Value="@Model.Entity.PayDetailCode"/>
      <Select @bind-Value="@Model.Entity.BuyId" Items="AllBuys" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="geb00fc72bcce4850a4ae6c6c00725d6d"/>
      <BootstrapInput @bind-Value="@Model.Entity.Amount1"/>
      <BootstrapInput @bind-Value="@Model.Entity.Amount2"/>
      <BootstrapInput @bind-Value="@Model.Entity.Amount3"/>
      <BootstrapInput @bind-Value="@Model.Entity.Amount4"/>
      <BootstrapInput @bind-Value="@Model.Entity.Remark"/>
    </Row>

    <div class="modal-footer table-modal-footer">
      <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
      <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
    </div>

  </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private PaymentDetailVM Model = new PaymentDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {
                        
        
        await PostsForm(vform, "/api/Fin/PaymentDetail/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllPays = new List<SelectedItem>();
    private List<SelectedItem> AllBuys = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllPays = await WtmBlazor.Api.CallItemsApi("/api/Fin/PaymentDetail/GetPayments");
        AllPays.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllBuys = await WtmBlazor.Api.CallItemsApi("/api/Fin/PaymentDetail/GetBuys");
        AllBuys.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
